package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaChongzhi;
import com.ruoyi.system.service.IJiajiaChongzhiService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充值栏目Controller
 * 
 * @author knd
 * @date 2021-10-13
 */
@Controller
@RequestMapping("/jiajia/chongZhi")
public class JiajiaChongzhiController extends BaseController
{
    private String prefix = "jiajia/chongZhi";

    @Autowired
    private IJiajiaChongzhiService jiajiaChongzhiService;

    @RequiresPermissions("jiajia:chongZhi:view")
    @GetMapping()
    public String chongZhi()
    {
        return prefix + "/chongZhi";
    }

    /**
     * 查询充值栏目列表
     */
    @RequiresPermissions("jiajia:chongZhi:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaChongzhi jiajiaChongzhi)
    {
        startPage();
        List<JiajiaChongzhi> list = jiajiaChongzhiService.selectJiajiaChongzhiList(jiajiaChongzhi);
        return getDataTable(list);
    }

    /**
     * 导出充值栏目列表
     */
    @RequiresPermissions("jiajia:chongZhi:export")
    @Log(title = "充值栏目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaChongzhi jiajiaChongzhi)
    {
        List<JiajiaChongzhi> list = jiajiaChongzhiService.selectJiajiaChongzhiList(jiajiaChongzhi);
        ExcelUtil<JiajiaChongzhi> util = new ExcelUtil<JiajiaChongzhi>(JiajiaChongzhi.class);
        return util.exportExcel(list, "充值栏目数据");
    }

    /**
     * 新增充值栏目
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存充值栏目
     */
    @RequiresPermissions("jiajia:chongZhi:add")
    @Log(title = "充值栏目", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaChongzhi jiajiaChongzhi)
    {
        return toAjax(jiajiaChongzhiService.insertJiajiaChongzhi(jiajiaChongzhi));
    }

    /**
     * 修改充值栏目
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaChongzhi jiajiaChongzhi = jiajiaChongzhiService.selectJiajiaChongzhiById(id);
        mmap.put("jiajiaChongzhi", jiajiaChongzhi);
        return prefix + "/edit";
    }

    /**
     * 修改保存充值栏目
     */
    @RequiresPermissions("jiajia:chongZhi:edit")
    @Log(title = "充值栏目", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaChongzhi jiajiaChongzhi)
    {
        return toAjax(jiajiaChongzhiService.updateJiajiaChongzhi(jiajiaChongzhi));
    }

    /**
     * 删除充值栏目
     */
    @RequiresPermissions("jiajia:chongZhi:remove")
    @Log(title = "充值栏目", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaChongzhiService.deleteJiajiaChongzhiByIds(ids));
    }
}
